import time
from selenium.webdriver.common.by import By
from pom.base_page import BasePage


class InfoManagePage(BasePage):
    def msg_manage(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[9]/li/ul/div[1]/a/li').click()

        time.sleep(2)
        category = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[3]/div').text
        describe = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[4]/div').text
        source = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[5]/div').text
        print(category, describe, source, "*******************************")

        assert category == "系统"
        assert describe == "测试"
        assert source == "系统"

    def msg_handle(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[9]/li/ul/div[2]/a/li').click()

        time.sleep(2)
        receiver = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[3]/div').text
        remarks = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr/td[4]/div').text
        print(receiver, remarks, "********************************")

        assert receiver == "1"
        assert remarks == "发送"

    def notice_manage(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[9]/li/ul/div[3]/a/li').click()

        time.sleep(2)
        notice_tittle = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        notice_type = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[4]/div').text
        creator = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[6]/div').text
        print(notice_tittle, notice_type, creator, "**********************************")

        assert notice_tittle == "温馨提醒：2018-07-01 新版本发布啦"
        assert notice_type == "公告"
        assert creator == "admin"
